<template>
  <div>
    <div class="state">
      <div class="details">文章详情</div>
      <div>
        <el-button @click="offlineDel('下线')">下线</el-button>
        <el-button type="info" @click="offlineDel('删除')">删除</el-button>
      </div>
    </div>
    <div class="message">
      <div class="title-model">
        <div class="img"><img :src="articleMessage.img" alt="" /></div>
        <div>
          <div class="title">{{ articleMessage.title }}</div>
          <div class="state">
            <div>{{ articleMessage.time }}</div>
            <div>{{ articleMessage.classificati }}</div>
            <div>{{ articleMessage.state }}</div>
          </div>
        </div>
      </div>
      <div v-html="articleMessage.text"></div>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { ref, watch } from "vue";
const props = defineProps(["viewData"]);
const emits = defineEmits(["closeEdit"]);
const articleMessage = ref({
  img: "",
  title: "",
  time: "",
  classificati: "",
  state: "",
  text: "",
});
articleMessage.value.img = props.viewData.img;
articleMessage.value.title = props.viewData.title;
articleMessage.value.time = props.viewData.time;
articleMessage.value.classificati = props.viewData.classificati;
articleMessage.value.state = props.viewData.state;
articleMessage.value.text = props.viewData.text;
const offlineDel = (i: string) => {
  ElMessageBox.confirm(`是否确认${i}该文章`, "提示", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
    draggable: true,
  })
    .then(() => {
      emits("closeEdit", false);
      ElMessage({
        type: "success",
        message: `${i}成功`,
      });
    })
    .catch(() => {
      ElMessage({
        type: "info",
        message: ``,
      });
    });
};
</script>
<style lang="scss" scoped>
.state {
  width: 70%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 5px;
  border-bottom: 10px solid #eee;

  .details {
    font-size: 20px;
    font-weight: 600;
  }
}

.message {
  .title-model {
    display: flex;

    .title {
      font-size: 20px;
      font-weight: 700;
    }

    .state {
      color: #9d9d9d;
      font-size: 13px;
    }
  }
}
</style>
